#include "stdafx.h"
#include "LitScriptEngineOgreWrappers.h"

namespace Lit
{
	namespace ScriptWrappers
	{
	// Ogre::Radian
		void RadianWrapper::Constructor0(Ogre::Radian *self){new(self) Ogre::Radian();}
		void RadianWrapper::DegreeConstructor(const Ogre::Degree& deg, Ogre::Radian *self){new(self) Ogre::Radian(deg);}
		void RadianWrapper::RealConstructor(Ogre::Real r, Ogre::Radian *self){new(self) Ogre::Radian(r);}
		void RadianWrapper::CopyConstructor(const Ogre::Radian &other, Ogre::Radian *self){new(self) Ogre::Radian(other.valueRadians());}
		int RadianWrapper::Compare(const Ogre::Radian &against, const Ogre::Radian *self){	if( *self == against ) return 0; if( against > *self ) return -1;return 1;}
	
	// Ogre::Degree
		void DegreeWrapper::Constructor0(Ogre::Degree *self){new(self) Ogre::Radian();}
		void DegreeWrapper::RadianConstructor(const Ogre::Radian& rad, Ogre::Degree *self){new(self) Ogre::Degree(rad);}
		void DegreeWrapper::RealConstructor(Ogre::Real r, Ogre::Degree *self){new(self) Ogre::Radian(r);}
		void DegreeWrapper::CopyConstructor(const Ogre::Degree &other, Ogre::Degree *self){new(self) Ogre::Degree(other.valueDegrees());}
		int DegreeWrapper::Compare(const Ogre::Degree &against, const Ogre::Degree *self){	if( *self == against ) return 0; if( against > *self ) return -1;return 1;}
	
	// Ogre::Vector3 - Lit::Vec3
		void Vector3Wrapper::Constructor0(Ogre::Vector3 *self){new(self) Ogre::Vector3();}
		void Vector3Wrapper::Constructor1(Ogre::Real scalar, Ogre::Vector3 *self){new(self) Ogre::Vector3(scalar);}
		void Vector3Wrapper::Constructor3( Ogre::Real x, Ogre::Real y, Ogre::Real z, Ogre::Vector3 *self){new(self) Ogre::Vector3(x,y,z);}
		void Vector3Wrapper::CopyConstructor(const Ogre::Vector3 &other, Ogre::Vector3 *self){new(self) Ogre::Vector3(other);}	
		int Vector3Wrapper::Compare(const Ogre::Vector3 &against, const Ogre::Vector3 *self){	if( *self == against ) return 0; if( against > *self ) return -1;return 1;}
	
	// Ogre::Vector2 - Lit::Vec2
		void Vector2Wrapper::Constructor0(Ogre::Vector2 *self){new(self) Ogre::Vector2();}
		void Vector2Wrapper::Constructor1( Ogre::Real scalar, Ogre::Vector2 *self ){new(self) Ogre::Vector2(scalar);}
		void Vector2Wrapper::Constructor2( Ogre::Real x, Ogre::Real y, Ogre::Vector2 *self){new(self) Ogre::Vector2(x,y);}
		void Vector2Wrapper::CopyConstructor(const Ogre::Vector2 &other, Ogre::Vector2 *self){new(self) Ogre::Vector2(other);}	
		int Vector2Wrapper::Compare(const Ogre::Vector2 &against, const Ogre::Vector2 *self){	if( *self == against ) return 0; if( against > *self ) return -1;return 1;}
	
	// Ogre::Vector4 - Lit::Vec4
		void Vector4Wrapper::Constructor0( Ogre::Vector4 *self ){new(self) Ogre::Vector4();}
		void Vector4Wrapper::Constructor1( const Ogre::Real scalar, Ogre::Vector4 *self ){new(self) Ogre::Vector4(scalar);}
		void Vector4Wrapper::Constructor4( const Ogre::Real x, const Ogre::Real y, const Ogre::Real z, const Ogre::Real w, Ogre::Vector4 *self ){new(self) Ogre::Vector4(x,y,z,w);}
		void Vector4Wrapper::ConstructorV3( const Ogre::Vector3 &vec, Ogre::Vector4 *self ){new(self) Ogre::Vector4(vec);}
		void Vector4Wrapper::CopyConstructor(const Ogre::Vector4 &other, Ogre::Vector4 *self){new(self) Ogre::Vector4(other);}	

	// Ogre::Matrix3 - Lit::Matrix3
		void Matrix3Wrapper::Constructor0( Ogre::Matrix3 *self ){new(self) Ogre::Matrix3();}
		void Matrix3Wrapper::Constructor9( Ogre::Real fEntry00, Ogre::Real fEntry01, Ogre::Real fEntry02,
                    Ogre::Real fEntry10, Ogre::Real fEntry11, Ogre::Real fEntry12,
                    Ogre::Real fEntry20, Ogre::Real fEntry21, Ogre::Real fEntry22, Ogre::Matrix3 *self ){
						new(self) Ogre::Matrix3(fEntry00, fEntry01, fEntry02,
												fEntry10, fEntry11, fEntry12,
												fEntry20, fEntry21, fEntry22);
		}
		void Matrix3Wrapper::CopyConstructor(const Ogre::Matrix3 &other, Ogre::Matrix3 *self){new(self) Ogre::Matrix3(other);};
		
		void QuaternionWrapper::Constructor4(Ogre::Real w, Ogre::Real x, Ogre::Real y, Ogre::Real z, Ogre::Quaternion *self){ 
			new(self) Ogre::Quaternion( w, x, y, z ); 
		}
		void QuaternionWrapper::ConstructorMat3( const Ogre::Matrix3 &mat , Ogre::Quaternion *self){ 
			new(self) Ogre::Quaternion( mat ); 
		}
		void QuaternionWrapper::ConstructorAngle( const Ogre::Radian &angle, const Ogre::Vector3 &axis, Ogre::Quaternion *self){ 
			new(self) Ogre::Quaternion( angle, axis ); 
		}
		void QuaternionWrapper::ConstructorAxes( const Ogre::Vector3 &v0, const Ogre::Vector3 &v1, const Ogre::Vector3 &v2, Ogre::Quaternion *self){ 
			new(self) Ogre::Quaternion( v0, v1, v2 ); 
		}
		void QuaternionWrapper::CopyConstructor(const Ogre::Quaternion &other, Ogre::Quaternion *self){ 
			new(self) Ogre::Quaternion( other ); 
		}

		SceneNodeWrp::SceneNodeWrp( Ogre::SceneNode * n ){ mNode = n; }
		SceneNodeWrp::SceneNodeWrp( ){ mNode = NULL; }
		SceneNodeWrp::SceneNodeWrp( const SceneNodeWrp& rk ){ mNode = rk.mNode; }
		SceneNodeWrp::~SceneNodeWrp(){}
			
		void SceneNodeWrp::con_0( SceneNodeWrp*self ){ new(self) SceneNodeWrp(); }
		void SceneNodeWrp::con_copy( const SceneNodeWrp& oth, SceneNodeWrp*self ){ new(self) SceneNodeWrp(oth); }

		void SceneNodeWrp::attachObject( EntityWrp& obj ){ if( !mNode || !obj.mNode ) return; mNode->attachObject( obj.mNode ); }
		void SceneNodeWrp::detachObject( EntityWrp& obj ){ if( !mNode || !obj.mNode ) return; mNode->detachObject( obj.mNode ); }
		void SceneNodeWrp::detachAllObjects( ){ if(!mNode) return; mNode->detachAllObjects(); }

		SceneNodeWrp SceneNodeWrp::createChildSceneNode(){ if(!mNode) return SceneNodeWrp(); return SceneNodeWrp( mNode->createChildSceneNode() ); }
			
		void SceneNodeWrp::setPosition( const Ogre::Vector3& pos ){ if(!mNode) return; mNode->setPosition( pos ); }
		void SceneNodeWrp::setPosition( Ogre::Real x, Ogre::Real y, Ogre::Real z ){ if(!mNode) return; mNode->setPosition( x, y, z ); }
		void SceneNodeWrp::setOrientation( const Ogre::Quaternion& pos ){ if(!mNode) return; mNode->setOrientation( pos ); }
		void SceneNodeWrp::setOrientation( Ogre::Real w, Ogre::Real x, Ogre::Real y, Ogre::Real z ){ if(!mNode) return; mNode->setOrientation( w, x, y, z ); }
		void SceneNodeWrp::setScale( const Ogre::Vector3& pos ){ if(!mNode) return; mNode->setPosition( pos ); }
		void SceneNodeWrp::setScale( Ogre::Real x, Ogre::Real y, Ogre::Real z ){ if(!mNode) return; mNode->setScale( x, y, z ); }
			
		Ogre::Vector3 SceneNodeWrp::getPosition() const{ return mNode?mNode->getPosition():Ogre::Vector3::ZERO; }
		Ogre::Quaternion SceneNodeWrp::getOrientation() const{ return mNode?mNode->getOrientation():Ogre::Quaternion::IDENTITY; }
		Ogre::Vector3 SceneNodeWrp::getScale() const{ return mNode?mNode->getScale():Ogre::Vector3::UNIT_SCALE; }

		void SceneNodeWrp::setVisible( bool vis, bool cascade ){ if( !mNode ) return; mNode->setVisible( vis, cascade ); }

		EntityWrp::EntityWrp( Ogre::Entity * n ){ mNode = n; }
		EntityWrp::EntityWrp( ){ mNode = NULL; }
		EntityWrp::EntityWrp( const EntityWrp& rk ){ mNode = rk.mNode; }
		EntityWrp::~EntityWrp(){}
			
		void EntityWrp::con_0( EntityWrp*self ){ new(self) EntityWrp(); }
		void EntityWrp::con_copy( const EntityWrp& oth, EntityWrp*self ){ new(self) EntityWrp(oth); }

		SceneNodeWrp EntityWrp::getParentSceneNode() const{ if(!mNode) return SceneNodeWrp(); return SceneNodeWrp(mNode->getParentSceneNode()); }

		void EntityWrp::detachFromParent(){ if(!mNode) return; mNode->detachFromParent(); }

		std::string EntityWrp::getName() const{ if(!mNode) return ""; return mNode->getName(); }
		std::string EntityWrp::getMeshName() const{ if(!mNode) return ""; return mNode->getMesh()->getName(); }
		std::string EntityWrp::getMaterialName( unsigned int id ) const{ if(!mNode) return ""; return mNode->getSubEntity(id)->getMaterialName(); }

		SceneMgrWrp::SceneMgrWrp( Ogre::SceneManager * n ){ mScene = n; }
		SceneMgrWrp::SceneMgrWrp( ){ mScene = NULL; }
		SceneMgrWrp::SceneMgrWrp( const SceneMgrWrp& rk ){ mScene = rk.mScene; }
		SceneMgrWrp::~SceneMgrWrp(){}
			
		void SceneMgrWrp::con_0( SceneMgrWrp*self ){ new(self) SceneMgrWrp(); }
		void SceneMgrWrp::con_copy( const SceneMgrWrp& oth, SceneMgrWrp*self ){ new(self) SceneMgrWrp(oth); }
			
		SceneNodeWrp SceneMgrWrp::getSceneNode( const std::string &name ){ if( !mScene ) return SceneNodeWrp(); return mScene->getSceneNode(name); }
		void SceneMgrWrp::destroySceneNode( SceneNodeWrp & node ){ if( mScene && node.mNode ) mScene->destroySceneNode(node.mNode); }
			
		EntityWrp SceneMgrWrp::getEntity( const std::string &name )
		{
			if(!mScene)return EntityWrp();
			return EntityWrp( mScene->getEntity(name) );
		}
		EntityWrp SceneMgrWrp::createEntity( const std::string &mesh, const std::string &name )
		{
			if(!mScene)return EntityWrp();
			if( name.empty() ) return EntityWrp( mScene->createEntity(mesh) );
			return EntityWrp( mScene->createEntity(mesh, name) );
		}
		void SceneMgrWrp::destroyEntity( const std::string &name )
		{
			if(!mScene)return ;
			return mScene->destroyEntity(name);
		}
		void SceneMgrWrp::destroyEntity( EntityWrp &name )
		{
			if(!mScene)return ;
			return mScene->destroyEntity(name.getName());
		}
		SceneNodeWrp SceneMgrWrp::getRootSceneNode(){ if( !mScene ) return SceneNodeWrp(); return SceneNodeWrp( mScene->getRootSceneNode() ); }
		void SceneMgrWrp::clearScene(){ if( mScene ) mScene->clearScene(); }
	};
};